package com.songcha.library_business.handler

import android.net.Uri
import com.songcha.library_business.util.BusinessJumpUtil
import com.songcha.library_common.LibraryCommon

class UriHandler {
    companion object{
        @JvmStatic
        fun handle(uriStr:String){
            if(uriStr.isBlank()) return
            val uri=Uri.parse(uriStr)

            when(uri.scheme){
                "http","https"->{
                    BusinessJumpUtil.toWebViewActivity(LibraryCommon.getContext(),uriStr)
                }
                "qmy"->{
                    when(uri.host){
                        "h5"->{
                            val url=uri.getQueryParameter("url")?:return
                            if(url.isBlank()) return
                            BusinessJumpUtil.toWebViewActivity(LibraryCommon.getContext(),url)
                        }
                    }
                }
                "image"->{
                    val url=uri.getQueryParameter("url")?:return
                    //val aspect_ratio=uri.getQueryParameter("aspect_ratio")?:return
                    try{
                        //val ratio=aspect_ratio.toFloat()
                        if(url.isBlank()) return
                        BusinessJumpUtil.toImageActivity(url)
                    }catch (e:Exception){
                        e.printStackTrace()
                    }

                }
            }

        }
    }
}